<?php

class CHCLegend extends AbstractHCObject
{
    
    /**
     *  The background color of the legend, filling the rounded corner border. 
     *  Defaults to null.
     *  
     * @param String $psColor
     */
    public function setBackgroundColor($psColor)
    {
        // default
        if ($psColor == 'null' || is_null($psColor)) return true;
        
        if (CSDebug::assertHex($psColor)) return false;
        
        $this->setParam('backgroundColor', $psColor);
    }
    
    
    /**
     *  The color of the drawn border around the legend. 
     *  
     *  Defaults to #909090.
     *  
     * @param $psColor
     */
    public function setBorderColor($psColor='#909090')
    {
        if (CSDebug::assertHex($psColor)) return false;
        
        $this->setParam('borderColor', $psColor);
    }
    
    
    /**
     *  The border corner radius of the legend. 
     *  
     *  Defaults to 5.
     *  
     * @param $pnInteger
     */
    public function setBorderRadius($pnInteger=5)
    {
        if (CSDebug::assertInteger($pnInteger)) return false;
        
        $this->setParam('borderRadius', $pnInteger);
    }
    
    
    /**
     *  The width of the drawn border around the legend. 
     *  
     *  Defaults to 0.
     *  
     * @param $pnInteger
     */
    public function setBorderWidth($pnInteger=0)
    {
        if (CSDebug::assertInteger($pnInteger)) return false;
        
        $this->setParam('borderWidth', $pnInteger);
    }
    
    
    /**
     *  Enable or disable the legend. 
     *  
     *  Defaults to true.
     *  
     * @param $pbBoolean
     */
    public function setEnabled($pbBoolean=true)
    {
        if (CSDebug::assertBoolean($pbBoolean)) return false;
        
        $this->setParam('enabled', $pbBoolean);
    }
    
    
    /**
     * CSS styles for each legend item when the corresponding series or point is hidden. 
     * Properties are inherited from style unless overridden here. 
     * 
     * Defaults to:
     * 	array
     * (
     * 		color => '#CCC'
     * ); 
     * 
     * @param $pasArray
     */
    public function setHiddenStyle($pasArray)
    {
        if (CSDebug::assertArray($pasArray)) return false;
        
        $this->setParam('itemHiddenStyle', $pasArray);
    }
    
    
    /**
     * CSS styles for each legend item in hover mode. Properties are inherited from style unless overridden here. 
     * 
     * Defaults to:
     *  
     * 	array
     * (
     * 		color => '#000'
     * ); 
     * 
     * @param $pasArray
     */
    public function setHoverStyle($pasArray)
    {
        if (CSDebug::assertArray($pasArray)) return false;
        
        $this->setParam('itemHoverStyle', $pasArray);
    }
    
    
    /**
     * CSS styles for each legend item. Defaults to:
     * array
     * (
     *		listStyle 	=> 'none',
     *		margin		=> '0 1em 0 0',
     *		padding 	=> 0,
     *		font 		=> '13px "Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif',
     *		cursor  	=> 'pointer',
     *		color 		=> '#3E576F'
     *);
     *
     * @param unknown_type $pasArray
     */
    public function setItemStyle($pasArray)
    {
        if (CSDebug::assertArray($pasArray)) return false;
        
        $this->setParam('itemItemStyle', $pasArray);
    }
    
    
    /**
     *  The layout of the legend items. 
     *  Can be one of "horizontal" or "vertical". 
     *  
     *  Defaults to "horizontal".
     * @param $psString
     */
    public function setLayout($psString='horizontal')
    {
        if (!in_array($psString, array('horizontal', 'vertical'))) return false;
        
        $this->setParam('layout', $psString);
    }
    
    
    /**
     * Callback function to format each of the series' labels. 
     * The this  keyword refers to the series object, or the point object in case of pie charts. 
     * 
     * Defaults to:
     * labelFormatter: function() { return this.name }
     * 
     * @param $psString
     */
    public function setLabelFormatter($psString)
    {
        if (CSDebug::assertString($psString)) return false;
        
        $this->setParam('labelFormatter', $this->tokenize($psString));
    }
    
    
    /**
     *  Whether to apply a drop shadow to the legend. 
     *  
     *  Defaults to true.
     *  
     * @param unknown_type $pbBoolean
     */
    public function setShadow($pbBoolean=true)
    {
        if (CSDebug::assertBoolean($pbBoolean)) return false;
        
        $this->setParam('shadow', $pbBoolean);
    }
    
    
    /**
     * CSS styles for the legend area. Defaults to:
     * array
     * (
     * 		position 	=> 'absolute',
     * 		zIndex 		=> 10,
     * 		bottom 		=> '10px',
     * 		left 		=> '80px',
     * 		padding 	=> '5px'
     * );
     * 
     * @param $pasArray
     */
    public function setStyle($pasArray)
    {
      if (CSDebug::assertArray($pasArray)) return false;
      
      $this->setParam('style', $pasArray);
    }
    
    
    /**
     * The pixel padding between the legend item symbol and the legend item text. 
     * 
     * Defaults to 5.
     * 
     * @param $pnInteger
     */
    public function setSymbolPadding($pnInteger=5)
    {
        if (CSDebug::assertInteger($pnInteger)) return false;
        
        $this->setParam('symbolPadding', $pnInteger);
    }
    
    
    /**
     *  The pixel width of the legend item symbol. 
     *  
     *  Defaults to 30.
     *  
     * @param $pnInteger
     */
    public function setSymbolWidth($pnInteger=30)
    {
        if (CSDebug::assertInteger($pnInteger, true)) return false;
        
        $this->setParam('symbolWidth', $pnInteger);
    }
}

?>